package com.platform.server.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.platform.server.dao.SystemUserDao;
import com.platform.server.service.SystemUserService;

@Service
public class SystemUserServiceImpl implements SystemUserService {
	
	@Autowired
	private SystemUserDao systemUserDao;

	/**
	 * 用户登录
	 */
	@Override
	public List<Map<String,Object>> userLogin(Map<String,Object> map) {
		return systemUserDao.userLogin(map);
	}

	/**
	 * 角色列表
	 */
	@Override
	public List<Map<String, Object>> sysRoleList(Map<String, Object> map) {
		return systemUserDao.sysRoleList(map);
	}

	/**
	 * 添加角色
	 */
	@Override
	public int insertSysRole(String role_name, String action_id, String action_name, String status) {
		return systemUserDao.insertSysRole(role_name, action_id, action_name, status);
	}

	/**
	 * 查看角色详细信息
	 */
	@Override
	public List<Map<String, Object>> selectSysRoleInfo(Integer role_id) {
		return systemUserDao.selectSysRoleInfo(role_id);
	}

	/**
	 * 修改角色信息
	 */
	@Override
	public int updateSysRole(Integer role_id, String role_name, String action_id, String action_name, String status) {
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("role_id", role_id);
		map.put("role_name",role_name);
		map.put("action_id", action_id);
		map.put("action_name", action_name);
		map.put("status", status);
		return systemUserDao.updateSysRole(map);
	}

	/**
	 * 删除角色
	 */
	@Override
	public int deleteRole(String id) {
		return systemUserDao.deleteRole(id);
	}

	/**
	 * 账号列表
	 */
	@Override
	public List<Map<String, Object>> getSysUserList(Map<String, Object> map) {
		return systemUserDao.getSysUserList(map);
	}

	/**
	 * 添加账号之前查看角色列表
	 */
	@Override
	public List<Map<String, Object>> sysRoleInfoList(Map<String, Object> map) {
		return systemUserDao.sysRoleList(map);
	}

	/**
	 * 添加账号
	 */
	@Override
	public int insertSysUser(String sys_phone, String sys_name, String sys_password, String sys_role,
			String sys_role_name, String company_name, String status) {
		return systemUserDao.insertSysUser(sys_phone, sys_name, sys_password, sys_role, sys_role_name, company_name, status);
	}

	/**
	 * 删除账号
	 */
	@Override
	public int deleteSysUser(String id) {
		return systemUserDao.deleteSysUser(id);
	}

	/**
	 * 查看用户详情
	 */
	@Override
	public List<Map<String, Object>> selectSysUserInfo(Long sys_id) {
		return systemUserDao.selectSysUserInfo(sys_id);
	}

	/**
	 * 修改账号信息
	 */
	@Override
	public int updateSysUser(String sys_phone, String sys_name, String sys_password, String sys_role,
			String sys_role_name, String company_name, String status, Integer sys_id) {
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("sysPhone", sys_phone);
		map.put("sysName",sys_name);
		map.put("sysPassword", sys_password);
		map.put("sysRole", sys_role);
		map.put("sysRoleName", sys_role_name);
		map.put("status", status);
		map.put("sysId", sys_id);
		return systemUserDao.updateSysUser(map);
	}
	
}
